package com.jicheng.mapper.template;

import com.jicheng.dto.task.TemplateFileDto;
import com.jicheng.entity.task.template.TemplateMap;
import com.jicheng.framework.mybatis.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface TemplateMapMapper extends BaseMapper<TemplateMap> {

    @Select("select count(1) from tb_template where id = #{templateId}")
    int isExist(@Param("templateId") String templateId);

    /**
     * 删除任务中的模板，这里采取逻辑删除
     * @param where
     * @param id
     */
    @Update("update tb_template set deleted = 1 where ${where} = #{id}")
    void delTemplate(@Param("where")String where,@Param("id") String id);

    @Select("select name fileName,img_path file ,create_time createTime from tb_template where task_id = #{taskId} order by create_time desc")
    List<TemplateFileDto> getTempDetail(@Param("taskId") String taskId);

    @Select("select name fileName,img_path file,create_time createTime  from tb_template where id = #{id}")
    TemplateFileDto getTemplateDetail(@Param("id") String id);
}
